package com.zhuhjay.service.system.model.dto;

import com.zhuhjay.common.web.annotation.Matching;
import com.zhuhjay.common.web.enums.MatchingMode;
import com.zhuhjay.service.system.model.entity.SystemConfig;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

/**
 * @author ZhuHJay
 * @date 2023/8/30 16:43
 */
@Data
public class ConfigDto {

    @ApiModelProperty("系统配置名称")
    @Matching(MatchingMode.ConfigName)
    private String configName;

    @ApiModelProperty("系统配置键名")
    @Matching(MatchingMode.ConfigKey)
    private String configKey;

    @ApiModelProperty("系统配置键值")
    @Length(min = 1, max = 512, message = "配置值长度必须在1-512字符之间")
    private String configValue;

    @ApiModelProperty("备注")
    @Length(max = 128, message = "备注长度不能超过128个字符")
    private String remark;

    public SystemConfig toEntity() {
        SystemConfig config = new SystemConfig();
        config.setConfigName(configName);
        config.setConfigKey(configKey);
        config.setConfigValue(configValue);
        config.setRemark(remark);
        return config;
    }

}
